<template>
  <div class="news">
      <h2>这是News组件</h2>
      <ul>
          <li v-for="item in list" :key="item.id">{{item.title}}</li>
      </ul>
      <button @click="addnews">点击添加一言</button>
  </div>
</template>

<script>
import {mapState,mapMutations} from 'vuex';
  export default {
    name:'News',
    computed:{
        ...mapState({list:'newsList'}),
    },
    methods: {
        ...mapMutations({addnews:'ADD_NEWS'}),
    },
  }
</script>

<style scoped>
    .news{
        background-color: #B9FAF8;
        padding: 20px;
    }
    ul{
        list-style: 0;
    }
</style>